package com.way.designpatterncodepratice.singleton;

/**
 * @author liangliwei 80551025
 * @description
 * @date 2020-06-22
 */
public class StaticInnerSingleton {


    private StaticInnerSingleton() {
        System.out.println("StaticInnerSingleton构造器");
    }

    /**
     * 静态内部类 要静态 不然内部类 变量或者方法不能通过static 修饰
     */
    public static class InnerClass{

        private static StaticInnerSingleton staticInnerSingleton = new StaticInnerSingleton();

//        private InnerClass() {
//            System.out.println("InnerClass 构造器");
//        }

        public static StaticInnerSingleton getInstance(){
//            if(staticInnerSingleton==null){
//                staticInnerSingleton = new StaticInnerSingleton();
//            }
            return InnerClass.staticInnerSingleton;
        }
    }

}
